package com.xxl.job.executor.service;

import com.xxl.job.executor.model.vo.ExecutorStatus;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class ExecutorStatusService {
    //todo 获取运行状态？
    private String status = "Runnig";
    @Value("${xxl.job.executor.appname}")
    private String appName;

    @Value("${xxl.job.executor.version}")
    private String version;

    @Value("${xxl.job.executor.logpath}")
    private String logPath;

    @Value("${xxl.job.executor.logretentiondays}")
    private int logRetentionDays;
    // todo 获取日志文件大小
    private int logSize;
    @Getter
    private final String system;

    public ExecutorStatusService() {
        this.system = System.getProperty("os.name");
    }

    public ExecutorStatus getExecutorStatus() {
        ExecutorStatus executorStatus = new ExecutorStatus();
        executorStatus.setStatus(status);
        executorStatus.setAppName(appName);
        executorStatus.setVersion(version);
        executorStatus.setLogPath(logPath);
        executorStatus.setLogRetentionDays(logRetentionDays);
        executorStatus.setLogSize(logSize);
        executorStatus.setSystem(system);
        return executorStatus;
    }
}
